package com.chuangke.fss.minio;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.minio.MinioClient;

@Configuration
@ConditionalOnClass(MinioClient.class)
@EnableConfigurationProperties( MinioProperties.class )
public class MinioAutoConfiguration {

	@Autowired
	private MinioProperties minioProperties;

	@Bean
	MinioClient minioClient() {
		return MinioClient.builder().endpoint(minioProperties.getUrl())
				.credentials(minioProperties.getAccessKey(),minioProperties.getSecretKey() ).build();
	}
}
